#!/bin/bash

echo "正在为场馆表添加排序字段..."

# 检查MySQL连接
mysql -u root -p -e "USE offgrid; SELECT 1;" > /dev/null 2>&1
if [ $? -ne 0 ]; then
    echo "错误: 无法连接到MySQL数据库"
    echo "请确保MySQL服务正在运行，并且数据库连接配置正确"
    exit 1
fi

echo "执行数据库迁移..."
mysql -u root -p offgrid < scripts/add-venue-sort-order.sql

if [ $? -eq 0 ]; then
    echo "✅ 场馆排序字段添加成功！"
    echo "字段信息:"
    mysql -u root -p -e "USE offgrid; DESCRIBE venues sort_order;"
else
    echo "❌ 场馆排序字段添加失败！"
fi

echo ""
echo "迁移完成！"
